﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using IDAL.RF.Repair;
using Model.RF.Repair;

namespace DAL.RF.Repair
{
    public class RepairConfig : BaseRepository<RepairConfigInfo>,IRepairConfig 
    {
        #region 静态变量定义部分
        private const string PARM_ID = "@ID";
        private const string PARM_REPAIRPATH = "@RepairPath";
        private const string PARM_REPAIRSTEP = "@RepairStep";
        #endregion
        
        #region 检索部分
        public IList<RepairConfigInfo> LoadEntities()
        {
            return null;
        }

        public RepairConfigInfo LoadEntity<T1>(T1 id)
        {
            return null;
        }

        public IList<RepairConfigInfo> RepairConfig_GetbyPath(string repairPath)
        {
            SqlParameter Parm = GetParameter_Path();
            Parm.Value = repairPath;
            return ExcuteSqlToGetEntities("RepairConfig_selectbyPath", Parm);
        }

        public void RepairConfig_RemovebyPath(string repairPath)
        {
            SqlParameter Parm = GetParameter_Path();
            Parm.Value = repairPath;
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.Add(Parm);
            ExecuteCommand(cmd, "RepairConfig_deletebyPath");
        }
        #endregion

        #region 参数部分
        public SqlParameter GetParameter_Path()
        {
            SqlParameter Parm = new SqlParameter(PARM_REPAIRPATH, SqlDbType.NVarChar, 50);
            return Parm;
        }
        #endregion

        #region 重写基类部分
        public override RepairConfigInfo GetEntityRecord(SqlDataReader rdr)
        {
            RepairConfigInfo pro = new RepairConfigInfo()
            {
                ID = rdr.GetInt32(0), 
                RepairPath= rdr.GetValue(1).ToString(), 
                RepairStep= rdr.GetValue(2).ToString() 
            };
            return pro;
        }

        public override RepairConfigInfo GetEntityRecord()
        {
            RepairConfigInfo pro = new RepairConfigInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "RepairConfig_insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_ID, SqlDbType.Int, 4),
                    new SqlParameter(PARM_REPAIRPATH, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_REPAIRSTEP, SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(RepairConfigInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.ID;
            Parms[1].Value = Entity.RepairPath;
            Parms[2].Value = Entity.RepairStep;
        }
        #endregion
    }
}
